<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>2.sessionStorage</title>
  </head>
  <body>
    <h2>sessionStorage的练习</h2>
    <button onclick="saveData()">存数据</button>
    <button onclick="readData()">取数据</button>
    <button onclick="deleteData()">删除数据</button>
    <button onclick="clearData()">清空数据</button>

    <script type="text/javascript" >
      function saveData(){
        // sessionStorage.setItem('n','100')
        // sessionStorage.setItem('m',100)

        let person = {name:'强哥',age:18}
        sessionStorage.setItem('ren',JSON.stringify(person))
      }
      function readData(){
        let result = sessionStorage.getItem('ren')
        // console.log(result)
        console.log(JSON.parse(result))
      }
      function deleteData(){
        sessionStorage.removeItem('ren')
      }
      function clearData(){
        sessionStorage.clear()
      }
    </script>

  </body>
</html>